<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="vue1026.js"></script>
    <script src="vue-router-0.7.3.js"></script>
</head>
<body>

    <div id="app">
        <a href="#" v-link="{path:'/account/login'}">登入</a>
        <a href="#" v-link="{path:'/account/register'}">注册</a>

        <!-- 占位来显示路由组件 -->
        <router-view></router-view>
    </div>

    <script>
    
    //实例化 Vue.组件
    var router = new VueRouter();

    //定义相关组件
    var App = Vue.extend({});

    var account = Vue.extend({
        template:'<router-view></router-view>'
    });

    var login = Vue.extend({
        template:'<h1>登入</h1>'
    });

    var register = Vue.extend({
        template:'<h1>注册</h1>'
    });
        //定义路由规则 
        //它是一个map
    router.map({
        'account':{
            component:account,
            subRoutes:{
                'login':{component:login},
                'register':{component:register}
            }
        },
        
    });
    //路由生效
    router.start(App,'#app');
        
    //默认显示的组件
    router.redirect({'/':'/account/login'});
    </script>

</body>
</html>